Attribute VB_Name = "MIniFile"
Option Explicit
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long

'== This module need Win32.tlb reference in the project
Public Function GetString(SectionName As String, KeyName As String, DefaultValue As String, Optional IniFileName As String) As String
    Dim KeyValueLength As Integer
    Dim KeyValue As String
    
    If Len(IniFileName) = 0 Then
        IniFileName = App.Path & "\" & App.EXEName & ".ini"
    End If
        
    KeyValue = Space$(256)
    '== read in the specified Ini file
    KeyValueLength = GetPrivateProfileString(SectionName, KeyName, DefaultValue, KeyValue, Len(KeyValue), IniFileName)

    GetString = Left$(KeyValue, KeyValueLength)
End Function




